package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.Registeredtype;
import com.ruoyi.web.service.IRegisteredtypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/*挂号类型*/
@RestController
@RequestMapping("/database/registeredtype")
public class RegisteredtypeController  extends BaseController {
    @Autowired
    private IRegisteredtypeService registeredtypeService;

    /**
     * 查询挂号类型列表
     */
    @PreAuthorize("@ss.hasPermi('database:registeredtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(Registeredtype registeredtype)
    {
        startPage();
        List<Registeredtype> list = registeredtypeService.selectRegisteredtypeList(registeredtype);
        return getDataTable(list);
    }

    /**
     * 获取【挂号类型】详细信息
     */
    @PreAuthorize("@ss.hasPermi('database:registeredtype:query')")
    @GetMapping(value = "/{registeredid}")
    public AjaxResult getInfo(@PathVariable("registeredid") Long registeredid)
    {
        return success(registeredtypeService.selectRegisteredtypeByRegisteredid(registeredid));
    }

    /**
     * 新增【挂号类型】
     */
    @PreAuthorize("@ss.hasPermi('database:registeredtype:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Registeredtype registeredtype)
    {
        return toAjax(registeredtypeService.insertRegisteredtype(registeredtype));
    }

    /**
     * 修改【挂号类型】
     */
    @PreAuthorize("@ss.hasPermi('database:registeredtype:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Registeredtype registeredtype)
    {
        return toAjax(registeredtypeService.updateRegisteredtype(registeredtype));
    }

}
